﻿using System.Collections.Generic;
using NUnit.Framework;
using StringExtensions;

namespace StringToDictionaryConverterTests
{
 [TestFixture]
  public class StrangeButTolerableSyntax
  {
    [Test]
    public void MissingValue()
    {
      const string sut = "a=";
      var result = sut.ToDictionary();
      var expected = new Dictionary<string, string> { {"a", ""} };

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void MissingKey()
    {
      const string sut = "=1";
      var result = sut.ToDictionary();
      var expected = new Dictionary<string, string> { { "", "1" } };

      Assert.That(result, Is.EqualTo(expected));
    }

    [Test]
    public void MissingValues()
    {
      const string sut = "a=;b=";
      var result = sut.ToDictionary();
      var expected = new Dictionary<string, string>
                       {
                         { "a", "" },
                         { "b", "" },
                       };

      Assert.That(result, Is.EqualTo(expected));
    }
  }
}
